home *** CD-ROM | disk | FTP | other *** search
/ NOVA - For the NeXT Workstation / NOVA - For the NeXT Workstation.iso / SourceCode / AdobeExamples / NX_ImportInt / epsferror.m < prev    next >
Encoding:
Text File  |  1992-12-19  |  2.7 KB  |  83 lines

  1.  
  2. /*
  3.  * (a)  (C) 1990 by Adobe Systems Incorporated. All rights reserved.
  4.  *
  5.  * (b)  If this Sample Code is distributed as part of the Display PostScript
  6.  *    System Software Development Kit from Adobe Systems Incorporated,
  7.  *    then this copy is designated as Development Software and its use is
  8.  *    subject to the terms of the License Agreement attached to such Kit.
  9.  *
  10.  * (c)  If this Sample Code is distributed independently, then the following
  11.  *    terms apply:
  12.  *
  13.  * (d)  This file may be freely copied and redistributed as long as:
  14.  *    1) Parts (a), (d), (e) and (f) continue to be included in the file,
  15.  *    2) If the file has been modified in any way, a notice of such
  16.  *      modification is conspicuously indicated.
  17.  *
  18.  * (e)  PostScript, Display PostScript, and Adobe are registered trademarks of
  19.  *    Adobe Systems Incorporated.
  20.  * 
  21.  * (f) THE INFORMATION BELOW IS FURNISHED AS IS, IS SUBJECT TO
  22.  *    CHANGE WITHOUT NOTICE, AND SHOULD NOT BE CONSTRUED
  23.  *    AS A COMMITMENT BY ADOBE SYSTEMS INCORPORATED.
  24.  *    ADOBE SYSTEMS INCORPORATED ASSUMES NO RESPONSIBILITY
  25.  *    OR LIABILITY FOR ANY ERRORS OR INACCURACIES, MAKES NO
  26.  *    WARRANTY OF ANY KIND (EXPRESS, IMPLIED OR STATUTORY)
  27.  *    WITH RESPECT TO THIS INFORMATION, AND EXPRESSLY
  28.  *    DISCLAIMS ANY AND ALL WARRANTIES OF MERCHANTABILITY, 
  29.  *    FITNESS FOR PARTICULAR PURPOSES AND NONINFRINGEMENT
  30.  *    OF THIRD PARTY RIGHTS.
  31.  */
  32.  
  33. /*
  34.  *    epsferror.c
  35.  *
  36.  *    Version:    2.0
  37.  *    Author:    Ken Fromm
  38.  *    History:
  39.  *            03-07-91        Added this comment.
  40.  */
  41.  
  42.  #import "epsfstruct.h"
  43.  
  44. #import <appkit/nextstd.h>
  45. #import <dpsclient/dpsclient.h>
  46. #import <dpsclient/wraps.h>
  47. #import <streams/streamsimpl.h>
  48.  
  49. static char  *errorStrings[ ] =
  50. {
  51. /* EPSF_OK */                    "EPSF file ok. ",
  52. /* EPSF_INVALIDPS */                "Not a valid EPSF file. ",
  53. /* EPSF_INVALIDPAGECOUNT */    "Invalid page count in EPSF file. ",
  54. /* EPSF_INVALIDBBOX */            "Invalid bounding box for the EPSF file. ",
  55. /* EPSF_INVALIDDOCUMENT */        "Invalid document included in the EPSF file. ",
  56. /* EPSF_ENDFILE */                "End file unexpectedly encountered in EPSF file. ",
  57. /* EPSF_WRITEERROR */            "Errors have been encountered in this EPSF file. ",
  58. /* EPSF_UNDEFINED */            "Undefined error in EPSF file. "
  59. };
  60.  
  61. char *ErrorEpsf(int errorcode)
  62. {
  63.     errorcode = MIN(errorcode, EPSF_ERRORCOUNT);    
  64.     return (errorStrings[errorcode]);
  65. }
  66.  
  67. /*  Log the error into a stream and then write the stream to stderr. */
  68. void  LogEpsfError(NXHandler *NXLocalHandler)
  69. {
  70.     char            *edata;
  71.  
  72.     int            elen, emaxlen;
  73.  
  74.     NXStream    *estream;
  75.  
  76.     estream = NXOpenMemory(NULL, 0, NX_WRITEONLY);
  77.     DPSPrintErrorToStream(estream, (DPSBinObjSeq) (NXLocalHandler->data2));
  78.     NXFlush(estream);
  79.     NXGetMemoryBuffer(estream, &edata, &elen, &emaxlen);
  80.     NXLogError("%s\n", edata);
  81.     NXCloseMemory(estream, NX_FREEBUFFER);
  82. }
  83.